import unittest


class TestDictMethods(unittest.TestCase):

    def test_create(self):
        dict1 = {'id': 1, 'name': 's1', 'age': 18}
        print(dict1['age'])
        dict1['age'] = 23
        print(dict1)

    """
    说明:
        1. dict1.items()方法返回的是一个元组, 可以使用for循环进行迭代.
    """
    def test_1(self):
        dict1 = {'id': 1, 'name': 's1', 'age': 18}
        print(dict1.get("age"))
        print(dict1.keys())
        print(dict1.items())
        for (x, y) in dict1.items():
            print(x, y)
        for x in dict1.items():
            print(x)


if __name__ == '__main__':
    unittest.main()
